package com.jvm.gc;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: csh
 * @Date: 2021/3/16 18:49
 * @Description:测试内存溢出
 *
 * -Xms9m -Xmx9m -XX:+PrintGCDetails
 */
public class GCTest {
    private static int i = 0;

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        try {
            String str=null;
            while (true){
                i++;
                str+="test";
                list.add(str);
            }
        }catch (Exception e){
            System.out.println("i"+i);
            e.printStackTrace();
        }
    }
}
